<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib uri="/WEB-INF/tld/fns.tld" prefix="fns" %>
<!DOCTYPE HTML>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <jsp:include page="/resources/inc/pageHead.jsp" />
</head>
<body>
<form class="layui-form" id="_form">
    <input type="hidden" name="id" value="${personalRecords.id}">
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">设置我的资料</div>
                    <%--//TODO 对邮件的管理--%>
                    <div class="layui-card-body" pad15="">
                        <div class="layui-form" lay-filter="">
                            <div class="layui-form-item">
                                <label class="layui-form-label">姓名</label>
                                <div class="layui-input-inline">
                                    <input type="text" value="${personalRecords.realname}" readonly="readonly"
                                           class="layui-input">
                                </div>
                                <div class="layui-form-mid layui-word-aux">不可修改。用户真实姓名</div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">工号</label>
                                <div class="layui-input-inline">
                                    <input type="text" value="${personalRecords.jobNumber}" readonly="readonly"
                                           class="layui-input ">
                                </div>
                                <div class="layui-form-mid layui-word-aux">不可修改。用户工号</div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">身份证号</label>
                                <div class="layui-input-inline">
                                    <input type="text" autocomplete="off" class="layui-input "
                                           readonly="readonly" value="${personalRecords.idcard}">
                                </div>
                                <div class="layui-form-mid layui-word-aux">不可修改。用户身份证号码</div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">工作部门</label>
                                <div class="layui-input-inline">
                                    <input type="text" readonly="readonly" class="layui-input "
                                           value="${personalRecords.organizationName}">
                                </div>
                                <div class="layui-form-mid layui-word-aux">不可修改。用户工作部门</div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">工作岗位</label>
                                <div class="layui-input-inline">
                                    <input type="text" readonly="readonly" class="layui-input "
                                           value="${personalRecords.positionName}">
                                </div>
                                <div class="layui-form-mid layui-word-aux">不可修改。用户工作岗位</div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">出生日期</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="birthday" autocomplete="off"
                                           value="<fmt:formatDate value='${personalRecords.birthday}' pattern='yyyy-MM-dd'/>"
                                           class="layui-input date-select" readonly="readonly" placeholder="请选择出生日期">
                                </div>
                                <div class="layui-form-mid layui-word-aux">可修改。用户出生日期</div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">手机号码</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="phone" autocomplete="off" placeholder="请输入手机号码"
                                           class="layui-input" value="${personalRecords.phone}">
                                </div>
                                <div class="layui-form-mid layui-word-aux">可修改。用户手机号码</div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">电子邮箱</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="email" autocomplete="off" placeholder="请输入电子邮箱"
                                           class="layui-input" value="${user.email}">
                                </div>
                                <div class="layui-form-mid layui-word-aux">可修改。用户电子邮箱</div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label">档案编号</label>
                                <div class="layui-input-inline">
                                    <input type="text" autocomplete="off" class="layui-input "
                                           readonly="readonly" value="${personalRecords.archiveNo}">
                                </div>
                                <div class="layui-form-mid layui-word-aux">不可修改。用户档案编号</div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">入职时间</label>
                                <div class="layui-input-inline">
                                    <input type="text" autocomplete="off"
                                           class="layui-input " readonly="readonly"
                                           value="<fmt:formatDate value='${personalRecords.joinedTime}' pattern='yyyy-MM-dd'/>">
                                </div>
                                <div class="layui-form-mid layui-word-aux">不可修改。用户入职时间</div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">转正日期</label>
                                <div class="layui-input-inline">
                                    <input type="text" autocomplete="off"
                                           class="layui-input " readonly="readonly"
                                           value="<fmt:formatDate value='${personalRecords.positiveTime}' pattern='yyyy-MM-dd'/>">
                                </div>
                                <div class="layui-form-mid layui-word-aux">不可修改。用户转正日期</div>
                            </div>


                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button class="layui-btn" lay-submit="" lay-filter="sub" type="button">确认修改</button>
                                    <button type="reset" class="layui-btn layui-btn-primary">重新填写</button>
                                </div>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
</form>
<jsp:include page="/resources/inc/pageFooter.jsp" />
<script>
    $(function () {
        var url = '${basePath}/oa/hr/personalRecords/updateUserInfo';
        var flag = false;
        layui.use(['laydate', 'form'], function () {
            var laydate = layui.laydate, form = layui.form;

            $(".date-select").each(function (index, input) {
                laydate.render({
                    elem: this //指定元素
                    , theme: '#393D49'
                });
            });
            form.on('submit(sub)', function (data) {
                var field = data.field;
                field.birthday = new Date(field.birthday).getTime();
                var phone = field.phone;
                if (phone.length > 0) {
                    var phoneReg = /^[1][3,4,5,7,8][0-9]{9}$/;
                    if (!phoneReg.test(phone)) {
                        layer.msg("请输入正确的手机号码", {icon: 5});
                        flag = true;
                    }
                }
                if (flag) {
                    flag = false;
                    return false;
                }
                $.ajax({
                    type: 'post',
                    url: url,
                    data: JSON.stringify(field),
                    contentType: "application/json;charset=utf-8",
                    success: function (res) {
                        if (res.code != 1) {
                            if (typeof(res.data) != "undefined" && res.data.length > 0) {
                                layer.msg(res.data, {icon: 5});
                            } else {
                                layer.msg(res.message, {icon: 5});
                            }
                        } else {
                            layer.msg('保存成功！');
                        }
                    },
                    error: function (res) {
                        console.log(res);
                    }
                });
            });
        });
    });

</script>
</body>
</html>
